package com.interview.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.interview.entity.Examee;
import com.interview.mapper.ExameeMapper;
import com.interview.service.DataDownLoadService;
import com.interview.service.ExameeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;

@Service
public class ExameeServiceImpl implements ExameeService {
    @Autowired
    private ExameeMapper exameeMapper;
    @Autowired
    private DataDownLoadService dataDownLoadService;

    @Override
    public List<Examee> getAllExamee() {
        return exameeMapper.selectList(null);
    }

    @Override
    public Examee getExameeById(String idNumber) {
        return exameeMapper.selectById(idNumber);
    }

    @Override
    public List<Examee> getExameeInfoByIdsFromDataCenter(String groupIds) {
        List<Examee> exameeList=dataDownLoadService.getExameeInfoByIdsFromDataCenter(groupIds);
        return exameeList;
    }

    @Override
    public int addExameeInfos(List<Examee> exameeList) {
        int i=0;
        for (Examee examee : exameeList) {
            exameeMapper.insert(examee);
            i++;
        }
        return i;
    }

    @Override
    public List<Examee> getExameeByIds(LinkedList<String> strings) {
        QueryWrapper<Examee> exameeQueryWrapper = new QueryWrapper<>();
        exameeQueryWrapper.in("group_id", strings);
        List<Examee> examees = exameeMapper.selectList(exameeQueryWrapper);
        return examees;
    }

}
